#ifndef LIGHT_H
#define LIGHT_H

#include "basicoject.h"
#include "OgreLight.h"

enum LightType {
    DIR, SPOT, POINT
};

class OLight : public BasicObject
{
    Q_OBJECT
    //Q_ENUMS(LightType)
    Q_PROPERTY(LightType lightType READ lightType WRITE setLightType)

    Q_PROPERTY(float xPos READ xPos WRITE setXPos)
    Q_PROPERTY(float yPos READ yPos WRITE setYPos)
    Q_PROPERTY(float zPos READ zPos WRITE setZPos)

    Q_PROPERTY(QString nodeId READ nodeId WRITE setNodeId)

    Q_PROPERTY(float difRed READ difRed WRITE setDifRed)
    Q_PROPERTY(float difGreen READ difGreen WRITE setDifGreen)
    Q_PROPERTY(float difBlue READ difBlue WRITE setDifBlue)

    Q_PROPERTY(float specRed READ specRed WRITE setSpecRed)
    Q_PROPERTY(float specGreen READ specGreen WRITE setSpecGreen)
    Q_PROPERTY(float specBlue READ specBlue WRITE setSpecBlue)

    Q_PROPERTY(float dirZ READ dirZ WRITE setDirZ)
    Q_PROPERTY(float dirX READ dirX WRITE setDirX)
    Q_PROPERTY(float dirY READ dirY WRITE setDirY)

public:
    explicit OLight(QObject *parent = 0);
    virtual ~OLight() {}

    void setLightType(LightType type) {
        m_type = type;
    }

    LightType lightType() const
    {
        return m_type;
    }

    ObjectType type() {
        return LIGHT;
    }

    virtual void setLight(Ogre::Light* light){
        m_light = light;
        updateDir();
    }

    // ---- positon

    float xPos() const ;
    float yPos() const;
    float zPos() const ;

    void setXPos(float pos);
    void setYPos(float pos);
    void setZPos(float pos);

    // ---- node
    QString nodeId() const {
        return m_nodeId;
    }

    void setNodeId(const QString& id) {
        this->m_nodeId = id;
    }

    // ---- diffuse colour

    float difRed() const {
        return m_DifRed;
    }

    float difGreen() const {
        return m_DifGreen;
    }

    float difBlue() const {
        return m_DifBlue;
    }

    void setDifRed(float c);
    void setDifGreen(float c);
    void setDifBlue(float c);

    // ---- specular colour

    float specRed() const {
        return m_specRed;
    }

    float specGreen() const {
        return m_specGreen;
    }

    float specBlue() const {
        return m_specBlue;
    }

    void setSpecRed(float c);
    void setSpecGreen(float c);
    void setSpecBlue(float c);

    // ---- direction

    float dirZ() const ;

    void setDirZ(float scale);

    float dirX() const;

    void setDirX(float scale);

    float dirY() const ;

    void setDirY(float scale);

signals:

public slots:

protected:
    void updatePos();
    void updateDir();

    LightType m_type;

    float m_xPos;
    float m_yPos;
    float m_zPos;

    float m_DifRed;
    float m_DifGreen;
    float m_DifBlue;

    float m_specRed;
    float m_specGreen;
    float m_specBlue;

    float m_dirZ;
    float m_dirX;
    float m_dirY;

    QString m_nodeId;

    Ogre::Light* m_light;
};

#endif // LIGHT_H
